package cn.fl.product.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.upload.api.IUploadApiService;
import cmm.comm.facade.upload.condition.SysUlDatCfgQueryCondition;
import cmm.comm.facade.upload.condition.SysUlFilesRecQueryCondition;
import cmm.comm.facade.upload.constant.UploadConstant;
import cmm.comm.facade.upload.dto.SysUlDatCfgDTO;
import cmm.comm.facade.upload.dto.SysUlDatCfgDtlDTO;
import cmm.comm.facade.upload.dto.SysUlFilesRecDTO;
import cmm.mid.core.framework.dto.DataResultDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.capital.constant.CapitalConstant;
import cn.fl.carsguar.transform.SplCarsGuarDtlInfoVOTransform;
import cn.fl.carsguar.vo.SplCarsGuarDtlInfoVO;
import cn.fl.flow.service.IFlowService;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.product.service.ISplInfoService;
import cn.fl.product.transform.SplPackageInfoVOTransform;
import cn.fl.product.vo.SplInfoVO;
import cn.fl.product.vo.SplPackageInfoVO;
import cn.fl.project.service.IPrjLnkCompService;
import cn.fl.project.vo.PrjFileInfoVO;
import cn.fl.project.vo.PrjLnkCompVO;
import cn.fl.system.vo.SysFlowManageVVO;
import cn.fl.system.vo.SysUlFilesRecVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.flow.facade.flow.api.IFlowApiService;
import fl.flow.facade.flow.api.IFlowQueryApiService;
import fl.flow.facade.flow.condition.SysFlowManageVQueryCondition;
import fl.flow.facade.flow.condition.SysFlowSHQueryCondition;
import fl.flow.facade.flow.constant.FlowConstant;
import fl.flow.facade.flow.dto.FlowStartParamsDTO;
import fl.flow.facade.flow.dto.FlowStartedDTO;
import fl.flow.facade.flow.dto.SysFlowSHDTO;
import fl.spl.facade.carsguar.condition.SplCarsGuarDtlInfoQC;
import fl.spl.facade.carsguar.dto.SplCarsGuarDtlInfoDTO;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.framework.enums.SplGrpRelInfoSrcEnum;
import fl.spl.facade.framework.enums.SplInfoFileCfgEnum;
import fl.spl.facade.propapply.api.ISplPackageInfoApiService;
import fl.spl.facade.propapply.api.ISplPropApplyInfoApiService;
import fl.spl.facade.propapply.condition.SplPackageInfoQC;
import fl.spl.facade.propapply.condition.SplPropApplyInfoQC;
import fl.spl.facade.propapply.dto.SplPackageInfoDTO;
import fl.spl.facade.propapply.dto.SplPropApplyInfoDTO;
import fl.spl.facade.spl.api.ISplExtInfoApiService;
import fl.spl.facade.spl.constant.SplInfoConstant;
import fl.spl.facade.spl.dto.SplExtInfoDTO;
import fl.spl.facade.spl.dto.SplInfoDTO;
import fl.spl.facade.store.api.ISplPropInfoApiService;
import fl.spl.facade.store.condition.SplPropInfoQueryCondition;
import fl.spl.facade.store.dto.SplPropInfoDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

@Controller
@RequestMapping("/spl/spepow")
public class SplSpePowController {

    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService ;

    @Autowired
    private ISplPropInfoApiService splPropInfoApiService ;

    @Autowired
    private IFlowApiService flowApiService ;

    @Autowired
    private IFlowQueryApiService flowQueryApiService ;

    @Autowired
    private IFlowService flowService ;

    @Autowired
    private ISplInfoService prdSplInfoService;

    @Autowired
    private ISplExtInfoApiService splExtInfoApiService;

    @Autowired
    private IUploadApiService uploadApiService ;

    @Autowired
    private ISplPropApplyInfoApiService splPropApplyInfoApiService ;
    @Autowired
    private ISplPackageInfoApiService splPackageInfoApiService;

    @Autowired
    private IPrjLnkCompService prjLnkCompService;

    @RequestMapping(value = "/toAddPage.do", method = {RequestMethod.GET})
    public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
        String splId = request.getParameter("splId");
        String isApply = request.getParameter("isApply");
        String id = request.getParameter("id");
        String isModify = request.getParameter("isModify");
        String noStartFlow = request.getParameter("noStartFlow");
        String isFlow = request.getParameter("isFlow");
        String needCloseTab = request.getParameter("needCloseTab");
        String isShowBigCustomer = request.getParameter("isShowBigCustomer");

        Map<String,String> map = sysDictionaryApiService.searchGroupToMap(SplSystemConstant.FL_SYS_CD,SplSystemConstant.DEFAULT_ORG_CD,"SPL0061");
        ModelAndView view = new ModelAndView("product/splInfo/splSpePowAddPage");
        String mdfFile = request.getParameter("mdfFile");
        view.addObject("mdfFile",mdfFile);
        view.addObject("propMap",map);
        view.addObject("splId",splId);
        view.addObject("isApply",isApply);
        view.addObject("isSpePow",request.getParameter("isSpePow"));
        if(StringUtils.isNotEmpty(id)){
            view.addObject("id",id);
        }else{
            SplPropInfoQueryCondition qc = new SplPropInfoQueryCondition();
            qc.setPropTypCd("006");
            qc.setIsDel(BaseConstant.IS_YESNO_NO);
            qc.setIsValid(BaseConstant.IS_YESNO_YES);
            qc.setSplId(Long.valueOf(splId));
            List<SplPropInfoDTO> dtoList = this.splPropInfoApiService.getSplPropInfoList(qc);
            if(CollectionUtils.isNotEmpty(dtoList)){
                view.addObject("id",dtoList.get(0).getId());
            }
        }
        view.addObject("isModify",isModify);
        view.addObject("noStartFlow",noStartFlow);
        view.addObject("saveBizFlowRl",1);
        view.addObject("isFlow",isFlow);
        view.addObject("needCloseTab",needCloseTab);
        //代偿担保附件配置
        view.addObject("tabNm", SplInfoFileCfgEnum.SPL023.getTableNm());
        view.addObject("cfgCd", SplInfoFileCfgEnum.SPL023.getCode());
        view.addObject("cfgOrgCd", SplInfoFileCfgEnum.SPL023.getOrgCd());
        view.addObject("cfgSysCd", SplInfoFileCfgEnum.SPL023.getSysCd());
        view.addObject("modulePath", SplInfoFileCfgEnum.SPL023.getModulePath());
        view.addObject("costomerPath", SplInfoFileCfgEnum.SPL023.getUploadCostomerPath());
        view.addObject("rootPath", SplInfoFileCfgEnum.SPL023.getUploadRootPath());
        view.addObject("uploadSysCd", SplInfoFileCfgEnum.SPL023.getUploadSysCd());
        //大客户附件配置
        view.addObject("tabNm2", SplInfoFileCfgEnum.SPL024.getTableNm());
        view.addObject("cfgCd2", SplInfoFileCfgEnum.SPL024.getCode());
        view.addObject("cfgOrgCd2", SplInfoFileCfgEnum.SPL024.getOrgCd());
        view.addObject("cfgSysCd2", SplInfoFileCfgEnum.SPL024.getSysCd());
        view.addObject("modulePath2", SplInfoFileCfgEnum.SPL024.getModulePath());
        view.addObject("costomerPath2", SplInfoFileCfgEnum.SPL024.getUploadCostomerPath());
        view.addObject("rootPath2", SplInfoFileCfgEnum.SPL024.getUploadRootPath());
        view.addObject("uploadSysCd2", SplInfoFileCfgEnum.SPL024.getUploadSysCd());
        if(StringUtils.isEmpty(isShowBigCustomer)){
            view.addObject("isShowBigCustomer",0);
        }else{
            view.addObject("isShowBigCustomer",isShowBigCustomer);
        }
        //商家端经销商准入流程信审审核节点标识
        view.addObject("isCreditReviewNode", request.getParameter("isCreditReviewNode"));
        return view ;
    }

    @RequestMapping(value = "/toAddBigCustomerPage.do", method = {RequestMethod.GET})
    public ModelAndView toAddBigCustomerPage(HttpServletRequest request, HttpServletResponse response) {
        String splId = request.getParameter("splId");
        String id = request.getParameter("id");
        String inFlow = request.getParameter("inFlow");
        String mdfFile = request.getParameter("mdfFile");
        String onlyShow = request.getParameter("onlyShow");

        Map<String,String> map = sysDictionaryApiService.searchGroupToMap(SplSystemConstant.FL_SYS_CD,SplSystemConstant.DEFAULT_ORG_CD,"SPL0061");
        ModelAndView view = new ModelAndView("product/splInfo/spePowBigCostomerAddPage");
        view.addObject("propMap",map);
        if(StringUtils.isNotEmpty(splId)) {
            view.addObject("splId", splId);
        }else{
            SplPropInfoDTO dto = this.splPropInfoApiService.getById(Long.valueOf(id));
            view.addObject("splId", dto.getSplId());
        }
        if(StringUtils.isNotEmpty(id)){
            view.addObject("id",id);
        }else{
            SplPropInfoQueryCondition qc = new SplPropInfoQueryCondition();
            qc.setPropTypCd("006");
            qc.setIsDel(BaseConstant.IS_YESNO_NO);
            qc.setIsValid(BaseConstant.IS_YESNO_YES);
            qc.setSplId(Long.valueOf(splId));
            List<SplPropInfoDTO> dtoList = this.splPropInfoApiService.getSplPropInfoList(qc);
            if(CollectionUtils.isNotEmpty(dtoList)){
                view.addObject("id",dtoList.get(0).getId());
            }
        }
        view.addObject("saveBizFlowRl",1);
        view.addObject("tabNm", SplInfoFileCfgEnum.SPL024.getTableNm());
        view.addObject("cfgCd", SplInfoFileCfgEnum.SPL024.getCode());
        view.addObject("cfgOrgCd", SplInfoFileCfgEnum.SPL024.getOrgCd());
        view.addObject("cfgSysCd", SplInfoFileCfgEnum.SPL024.getSysCd());
        view.addObject("modulePath", SplInfoFileCfgEnum.SPL024.getModulePath());
        view.addObject("costomerPath", SplInfoFileCfgEnum.SPL024.getUploadCostomerPath());
        view.addObject("rootPath", SplInfoFileCfgEnum.SPL024.getUploadRootPath());
        view.addObject("uploadSysCd", SplInfoFileCfgEnum.SPL024.getUploadSysCd());
        view.addObject("inFlow",inFlow);
        view.addObject("mdfFile",mdfFile);
        view.addObject("onlyShow",onlyShow);
        return view ;
    }

    @RequestMapping(value = "/initData.do", method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public Object initData(HttpServletRequest request, HttpServletResponse response) {
        String isApply = request.getParameter("isApply");
        String splId = request.getParameter("splId");
        String id = request.getParameter("id");
        SplPropInfoDTO dto = null;
        SplCarsGuarDtlInfoVO carsGuarVO = new SplCarsGuarDtlInfoVO();
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,"查询成功");

        List<String> dataList = new ArrayList<>();
        SplInfoVO splInfoVO = null ;
        if(StringUtils.isNotEmpty(isApply) && isApply.equals("1")){
            dto = this.splPropInfoApiService.getById(Long.valueOf(id));
        }else{
             SplPropInfoQueryCondition qc = new SplPropInfoQueryCondition();
             qc.setPropTypCd("006");
             qc.setIsDel(BaseConstant.IS_YESNO_NO);
             qc.setIsValid(BaseConstant.IS_YESNO_YES);
             qc.setSplId(Long.valueOf(splId));

             List<SplPropInfoDTO> dtoList = this.splPropInfoApiService.getSplPropInfoList(qc);
             if(CollectionUtils.isNotEmpty(dtoList)){
                 dto = dtoList.get(0);
             }
        }
        if(dto != null){
            String propInfo = dto.getPropInfo();
            String[] propInfoArray = propInfo.split(";");
            for (String s : propInfoArray) {
                dataList.add(s);
            }
            SplCarsGuarDtlInfoQC condition = new SplCarsGuarDtlInfoQC();
            condition.setIsDel(BaseConstant.IS_YESNO_NO);
            /*if(StringUtils.isNotEmpty(isApply) && isApply.equals("1")){
                condition.setIsValid(2);
            }else{
                condition.setIsValid(BaseConstant.IS_YESNO_YES);
            }*/
            condition.setPropId(dto.getId());
            List<SplCarsGuarDtlInfoDTO> carsGuarDtlInfoDTOList = this.splPropInfoApiService.searchCarsGuarList(condition);
            if(CollectionUtils.isNotEmpty(carsGuarDtlInfoDTOList)){
                SplCarsGuarDtlInfoDTO splCarsGuarDtlInfoDTO = carsGuarDtlInfoDTOList.get(0);
                if (StringUtils.isNotEmpty(splCarsGuarDtlInfoDTO.getGuarLnkCompId())) {
                    PrjLnkCompVO prjLnkCompVO = this.prjLnkCompService.selectById(splCarsGuarDtlInfoDTO.getGuarLnkCompId());
                    if (prjLnkCompVO != null && StringUtils.isNotEmpty(prjLnkCompVO.getLnkCompNm())) {
                        splCarsGuarDtlInfoDTO.setGuarLnkCompNm(prjLnkCompVO.getLnkCompNm());
                    }
                }
                carsGuarVO = SplCarsGuarDtlInfoVOTransform.toVO(splCarsGuarDtlInfoDTO);
            }
            splInfoVO = this.prdSplInfoService.selectById(dto.getSplId());
        }

        JSONObject obj = new JSONObject();
        obj.put("dataList",dataList);
        obj.put("carsGuar",carsGuarVO);
        if(null != splInfoVO) {
            obj.put("prjLvlCd", splInfoVO.getPrjLvlCd());
        }
        result.setData(obj);
        return result ;
    }

    @RequestMapping(value = "/addOrModify.do", method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public Object addOrModify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,"修改成功");
        String isApply = request.getParameter("isApply");
        String propinfo = request.getParameter("prop");
        String splId = request.getParameter("splId");
        String noStartFlow = request.getParameter("noStartFlow");
        String id = request.getParameter("id");
        String prjLvlCd = request.getParameter("prjLvlCd");
        String fileParams2 = request.getParameter("fileParams2");//附件信息
        String packageParams = request.getParameter("packageParams");

        try {
            if(StringUtils.isNotEmpty(prjLvlCd) && propinfo.contains("7")){
                SplInfoVO splInfoVO = new SplInfoVO();
                splInfoVO.setId(Long.valueOf(splId));
                splInfoVO.setPrjLvlCd(prjLvlCd);
                splInfoVO.setMdfTm(new Date());
                splInfoVO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
                this.prdSplInfoService.modify(splInfoVO);
                if(StringUtils.isNotEmpty(packageParams)){
                    List<SplPackageInfoVO> packageInfoVOList = JSON.parseArray(packageParams, SplPackageInfoVO.class);
                    if(CollectionUtils.isNotEmpty(packageInfoVOList)){
                        for (SplPackageInfoVO packageInfoVO:packageInfoVOList) {
                            packageInfoVO.setSplId(Long.valueOf(splId));
                            packageInfoVO.setIsValid(BaseConstant.IS_YESNO_YES);
                            packageInfoVO.setIsDel(BaseConstant.IS_YESNO_NO);
                            packageInfoVO.setCrtTm(new Date());
                            packageInfoVO.setCrtUsrId(cn.lionbridge.center.context.CurrentThreadContext.getCurrentUserId());
                        }
                    }
                    this.splPackageInfoApiService.batchAddOrModify(SplPackageInfoVOTransform.toDTOList(packageInfoVOList));
                }
                if (StringUtils.isNotBlank(fileParams2)) {
                    List<SysUlFilesRecDTO> addFileList = new ArrayList<>();
                    List<SysUlFilesRecDTO> modifyFileList = new ArrayList<>();
                    List<PrjFileInfoVO> fileParamList = JSON.parseArray(fileParams2, PrjFileInfoVO.class);
                    if(CollectionUtils.isNotEmpty(fileParamList)){
                        BaseLogUtils.newLogger("附件信息").setKeys("fileParamList.size()",fileParamList.size()+"").info();
                        SysUlFilesRecDTO filesRecDTO ;
                        List<String> cfgDtlList = new ArrayList<>();
                        for (PrjFileInfoVO fileInfoVO : fileParamList) {
                            cfgDtlList.add(fileInfoVO.getCfgDtlCd());
                        }
                        for (PrjFileInfoVO fileInfoVO : fileParamList) {
                            filesRecDTO = new SysUlFilesRecDTO();
                            filesRecDTO.setFilePath(fileInfoVO.getFilePath());
                            filesRecDTO.setFileNm(fileInfoVO.getFileNm());
                            filesRecDTO.setCfgCd(SplInfoFileCfgEnum.SPL024.getCode());
                            filesRecDTO.setTabNm(SplInfoFileCfgEnum.SPL024.getTableNm());
                            filesRecDTO.setSysCd(SplInfoFileCfgEnum.SPL024.getSysCd());
                            filesRecDTO.setCfgDtlCd(fileInfoVO.getCfgDtlCd());
                            filesRecDTO.setOrgCd(fileInfoVO.getOrgCd());
                            filesRecDTO.setAbsLocPath(PropertiesCacheUtils.getProperty(SplInfoFileCfgEnum.SPL024.getUploadRootPath())+fileInfoVO.getFilePath());
                            filesRecDTO.setCrtTm(new Date());
                            filesRecDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                            filesRecDTO.setIsDel(BaseConstant.IS_YESNO_NO);
                            filesRecDTO.setPkId(splId);
                            //默认验证状态:未验证
                            if(StringUtils.isNotEmpty(fileInfoVO.getAudStsCd())){
                                filesRecDTO.setAudStsCd(fileInfoVO.getAudStsCd());
                            }else {
                                filesRecDTO.setAudStsCd(PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_VALID_STATUS_CD_A));
                            }
                            if (StringUtils.isNotEmpty(fileInfoVO.getFileId())) {
                                filesRecDTO.setId(fileInfoVO.getFileId());
                                modifyFileList.add(filesRecDTO);
                            }else{
                                addFileList.add(filesRecDTO);
                            }
                            //fileList.add(filesRecVO);
                        }
                        if(CollectionUtils.isNotEmpty(modifyFileList)){
                            this.uploadApiService.modifySysUlFilesRecList(modifyFileList);
                        }
                        if(CollectionUtils.isNotEmpty(addFileList)){
                            this.uploadApiService.addSysUlFilesRecList(addFileList);
                        }
                    }else{
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
                        result.setInfo("请上传附件信息!");
                        return result ;
                    }
                }else {
                    result.setSuccess(BaseConstant.IS_YESNO_NO);
                    result.setInfo("请上传附件信息!");
                    return result ;
                }
            }
            SplPropInfoQueryCondition condition = new SplPropInfoQueryCondition();
            condition.setSplId(Long.valueOf(splId));
            //condition.setIsValid(BaseConstant.IS_YESNO_YES);
            condition.setIsDel(BaseConstant.IS_YESNO_NO);
            condition.setPropTypCd("006");
            List<SplPropInfoDTO> propList = this.splPropInfoApiService.getSplPropInfoList(condition);
            BaseLogUtils.newWebLogger("查询现有特殊业务").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setKeys("propList", JSON.toJSONString(propList))
                    .setWarning(false)
                    .info();
        if(StringUtils.isEmpty(id)){
            if(CollectionUtils.isNotEmpty(propList)){
                id = propList.get(0).getId().toString();
            }
        }
        SplPropInfoDTO dto = new SplPropInfoDTO();
        if(StringUtils.isEmpty(splId)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("供应商ID为空，修改失败！");
            return result ;
        }
        //变更后 , 所选特殊业务为空不发起流程, 只选了保证金担保业务不发起流程，可以直接保存
        if (StringUtils.isEmpty(propinfo) || "8".equals(propinfo)) {
            noStartFlow = BaseConstant.IS_YESNO_YES_STR;
        }
        if(StringUtils.isNotEmpty(propinfo) && propinfo.contains("9")){
            result = this.getCarsGuarVOByParams(request);
            if(result.getSuccess() == BaseConstant.IS_YESNO_YES){
                SplCarsGuarDtlInfoVO carsGuarDtlInfoVO = (SplCarsGuarDtlInfoVO)result.getData();
                dto.setCarsGuarDtlInfoDTO(SplCarsGuarDtlInfoVOTransform.toDTO(carsGuarDtlInfoVO));
            }else{
                return result ;
            }
            result.setData(null);
        }
        try {
            if (StringUtils.isEmpty(noStartFlow) || !"1".equals(noStartFlow)) {
                SplInfoDTO splInfoDTO = this.splExtInfoApiService.selectPrdSplInfonById(Long.valueOf(splId), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
                if(null != splInfoDTO && ("0".equals(splInfoDTO.getAudStsCd()) || "3".equals(splInfoDTO.getAudStsCd()))){
                    noStartFlow = BaseConstant.IS_YESNO_YES_STR;
                }
            }
            if(StringUtils.isNotEmpty(isApply)){
                if(StringUtils.isNotEmpty(id)) {
                    dto.setPropInfo(propinfo);
                    dto.setId(Long.valueOf(id));
                    dto.setPropTypCd("006");
                    this.splPropInfoApiService.modify(dto);
                    result.setData(id);
                    BaseLogUtils.newWebLogger("特殊业务变更中,修改成功").setLogOperType(LogOperEnum.REQ)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                            .setWarning(false)
                            .info();
                }else{
                    dto.setPropInfo(propinfo);
                    dto.setPropTypCd("006");
                    dto.setIsDel(BaseConstant.IS_YESNO_NO);
                    dto.setIsValid(BaseConstant.IS_YESNO_YES);
                    dto.setSplId(Long.valueOf(splId));
                    dto.setCrtTm(new Date());
                    dto.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    Long addid = this.splPropInfoApiService.addSplPropInfoDTO(dto);
                    result.setData(addid);
                    BaseLogUtils.newWebLogger("准入中,新增成功").setLogOperType(LogOperEnum.REQ)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                            .setWarning(false)
                            .info();
                }
            }else{
                if(CollectionUtils.isNotEmpty(propList)){
                    List<Long> dataIds = new ArrayList<>();
                    List<String> audStsCdList = new ArrayList<>(3);
                    audStsCdList.add(FlowConstant.FLOW_CHECK_STATE_IN);
                    audStsCdList.add(FlowConstant.FLOW_CHECK_STATE_REJECT);
                    audStsCdList.add(FlowConstant.FLOW_CHECK_STATE_SUBMIT);
                    for (SplPropInfoDTO propDTO:propList) {
                        dataIds.add(propDTO.getId());
                    }

                    //查询流程历史
                    SysFlowSHQueryCondition shQueryCondition = new SysFlowSHQueryCondition();
                    shQueryCondition.setDataIdList(dataIds);
                    shQueryCondition.setBusTyp("048");
                    shQueryCondition.setWordsInTheTable(SplInfoConstant.SPL_FLOW_S_H_SPL);
                    shQueryCondition.setStatus(BaseConstant.IS_YESNO_YES);
                    shQueryCondition.setSysCd(SplSystemConstant.FL_SYS_CD);
                    shQueryCondition.setAudStsCdList(audStsCdList);
                    List<SysFlowSHDTO> sysFlowSHDTOs = this.flowQueryApiService.searchFlowSHList(shQueryCondition);
                    BaseLogUtils.newWebLogger("查询正在审核中的流程").setLogOperType(LogOperEnum.REQ)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                            .setKeys("sysFlowSHDTOs", JSON.toJSONString(sysFlowSHDTOs))
                            .setWarning(false)
                            .info();
                    if(CollectionUtils.isNotEmpty(sysFlowSHDTOs)){
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
                        result.setInfo("因存在审核中流程，不支持权限修改！");
                        result.setData(id);
                        return result ;
                    }
                    if(propinfo.equals(propList.get(0).getPropInfo())){
                        dto.setPropInfo(propinfo);
                        dto.setMdfTm(new Date());
                        dto.setId(propList.get(0).getId());
                        dto.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
                        this.splPropInfoApiService.modify(dto);
                        result.setSuccess(BaseConstant.IS_YESNO_YES);
                        result.setInfo("修改成功，权限未发生变化！");
                        result.setData(propList.get(0).getId());
                        return result ;
                    }
                    /*if (StringUtils.isNotEmpty(noStartFlow) && "1".equals(noStartFlow)) {
                        List<Long> delIdList = new ArrayList<>(propList.size());
                        for (SplPropInfoDTO splPropInfoDTO : propList) {
                            delIdList.add(splPropInfoDTO.getId());
                        }
                        this.splPropInfoApiService.removeByIds(delIdList);
                    }*/
                }

                dto.setSplId(Long.valueOf(splId));
                dto.setIsDel(BaseConstant.IS_YESNO_NO);
                dto.setIsValid(2);
                if (StringUtils.isNotEmpty(noStartFlow) && "1".equals(noStartFlow)) {
                    dto.setIsValid(BaseConstant.IS_YESNO_YES);
                }
                dto.setPropInfo(propinfo);
                dto.setPropTypCd("006");
                dto.setCrtTm(new Date());
                dto.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                Long propAddId = null ;
                if(StringUtils.isEmpty(id) ) {
                    propAddId= this.splPropInfoApiService.addSplPropInfoDTO(dto);
                    result.setData(propAddId);
                }else{
                    if(!"1".equals(noStartFlow)){
                        propAddId= this.splPropInfoApiService.addSplPropInfoDTO(dto);
                        result.setData(propAddId);
                    }else {
                        dto.setId(Long.valueOf(id));
                        this.splPropInfoApiService.modify(dto);
                        propAddId = Long.valueOf(id);
                        result.setData(id);
                    }
                }
                BaseLogUtils.newWebLogger("添加特殊业务项").setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                        .setKeys("propId", propAddId.toString())
                        .setWarning(false)
                        .info();

                if (StringUtils.isEmpty(noStartFlow) || !"1".equals(noStartFlow)) {
                    FlowStartedDTO flowStartedDTO = this.addFlowStart(propAddId,"048");
                    if(flowStartedDTO!= null && StringUtils.isNotBlank(flowStartedDTO.getNextOperUsrNames())){
                        result.setInfo("下一个节点操作人:"+flowStartedDTO.getNextOperUsrNames());
                    }else{
                        result.setInfo("流程发起成功");
                    }
                }
            }
        } catch (Exception e) {
            BaseLogUtils.newWebLogger("处理经销商特殊业务失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(e.getMessage());
        }
        }catch (BaseException be){
            result.setInfo(be.getMessage());
            result.setSuccess(BaseConstant.IS_YESNO_NO);
        }catch (Exception ex){
            result.setInfo(ex.getMessage());
            result.setSuccess(BaseConstant.IS_YESNO_NO);
        }
        return result;
    }

    private FlowStartedDTO addFlowStart(Long applyId,String modelTyp){

        //String procDefKey = "FLOW_0000_039_002" ;//request.getParameter("procDefKey");
        //String procDefId = null ;//request.getParameter("procDefId");
        //String procNo = null ;//request.getParameter("procNo");
        FlowStartParamsDTO flowStartParamsDTO = new FlowStartParamsDTO();
        try {
            Map<String,Object> params = new HashMap<>();
            if("049".equals(modelTyp)){
                params.put("allPass",1);
            }
            SysFlowManageVQueryCondition qc = new SysFlowManageVQueryCondition();
            qc.setModelTyp(modelTyp);
            qc.setSysCd(SplSystemConstant.FL_SYS_CD);
            qc.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);
            List<SysFlowManageVVO> list = this.flowService.searchFlowManageVListForStart(qc);
            BaseLogUtils.newWebLogger("查询可发起的流程").setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setKeys("sysFlowManageVVOList", JSON.toJSONString(list))
                    .info();
            if(CollectionUtils.isNotEmpty(list)){
                SysFlowManageVVO vvo = list.get(0);
                // 流程定义Key和流程定义ID 如果是前端选择的则直接指定,如果不是则系统自动按照配置选择唯一一条记录,如果找不到会提示
                flowStartParamsDTO.setAudStsCd(FlowConstant.FLOW_CHECK_STATE_IN);

                flowStartParamsDTO.setWordsInTheTable(SplInfoConstant.SPL_FLOW_S_H_SPL);
                // 流程定义标识(必填)
                flowStartParamsDTO.setProcDefKey(vvo.getProcDefKey());
                // 流程定义ID(必填)
                flowStartParamsDTO.setProcDefId(vvo.getProcDefId());
                // 流程定义名称(自定义)
                flowStartParamsDTO.setProcNo(vvo.getProcNo());

                flowStartParamsDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                // 业务数据主键(必填)
                flowStartParamsDTO.setBusinessKey(applyId + "");
                flowStartParamsDTO.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
                flowStartParamsDTO.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
                flowStartParamsDTO.setSysCd(CurrentThreadContext.getCurrentSysCd());
                flowStartParamsDTO.setInitiator(String.valueOf(CurrentThreadContext.getCurrentUserId()));
                flowStartParamsDTO.setInitiatorNm(CurrentThreadContext.getCurrentUserName());
                flowStartParamsDTO.setProcPriority(FlowConstant.FLOW_PRIORITY_EMERGENCY);// 优先级,可以在界面定义
                // 业务类型(必填)-用于区分操作表标识
                flowStartParamsDTO.setBusinessType(FlowConstant.FLOW_BUSINESS_TYP_SPL_BSC_INFO);// 确认用不用
                flowStartParamsDTO.setStartParams(params);
                // 模块类型(流程业务分类): 针对直接启动流程的业务使用
                flowStartParamsDTO.setModelTyp(modelTyp);// 需要和流程配置中的模块类型匹配
                flowStartParamsDTO.setSearchDesc(CurrentThreadContext.getCurrentOrgDispNm() + "特殊业务/大客户业务流程大字段参数未定!");
                DataResultDTO dataResultDTO = this.flowApiService.noTransFlowStart(flowStartParamsDTO);
                if(BaseConstant.IS_YESNO_YES != dataResultDTO.getSuccess()){
                    BaseLogUtils.newWebLogger("发起流程失败,业务异常").setLogOperType(LogOperEnum.REQ)
                            .setSysCd(CurrentThreadContext.getCurrentSysCd())
                            .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                            .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                            .setWarning(false)
                            .setKeys("message",dataResultDTO.getInfo())
                            .warn(LogExceptionEnum.COMMON_CODE_0001);
                }
                if(null!=dataResultDTO && null!=dataResultDTO.getData()){
                    FlowStartedDTO flowStartedDTO = (FlowStartedDTO) dataResultDTO.getData();
                    return flowStartedDTO;
                }
            }
        } catch (BaseException e) {
            BaseLogUtils.newWebLogger("发起供应商特殊权限变更流程失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .warn(LogExceptionEnum.COMMON_CODE_0001);
            e.getStackTrace();
        } catch (Exception e) {
            BaseLogUtils.newWebLogger("发起供应商特殊权限变更流程失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SQOT_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
            e.getStackTrace();
        }
        return null;
    }

    /**
     * 到详情页面
     */
    @RequestMapping(value = "/toSplDetailPage.do", method = { RequestMethod.GET, RequestMethod.POST })
    public ModelAndView toSplDetailPage(HttpServletRequest request, HttpServletResponse response) {
        //属性表ID
        String id = request.getParameter("id");
        String splAttrCd ;//供应商属性
        String qualTypCd ; //资质类型
        String isFlow = request.getParameter("isFlow"); //是否流程中打开 1：是
        String taskNm = request.getParameter("taskNm");
        String taskDefKey = request.getParameter("taskDefKey");
        String isSpePow = request.getParameter("isSpePow");
        ModelAndView view = new ModelAndView("product/splInfo/prdSplInfoDetail");
        view.addObject("isFlow",isFlow);
        view.addObject("isSpePow",isSpePow);
        String mdfFile = request.getParameter("mdfFile");
        view.addObject("mdfFile",mdfFile);
        String isShowBigCustomer = request.getParameter("isShowBigCustomer");
        String isBigCustomerFlow = request.getParameter("isBigCustomerFlow");
        String onlyShow = request.getParameter("onlyShow");
        view.addObject("isShowBigCustomer",isShowBigCustomer);//是否显示大客户业务选项
        view.addObject("isBigCustomerFlow",isBigCustomerFlow);//是否显示大客户业务选项
        view.addObject("onlyShow",onlyShow);
        SplPropInfoDTO propInfo = this.splPropInfoApiService.getById(Long.valueOf(id));

        SplInfoVO splInfoVO = this.prdSplInfoService.selectById(propInfo.getSplId());
        splAttrCd = splInfoVO.getSplAttrCd();

        qualTypCd = splInfoVO.getQualTypCd();

        view.addObject("qualTypCd", qualTypCd);

        view.addObject("splAttrCd", splAttrCd);

        view.addObject("currentUserId", CurrentThreadContext.getCurrentUserId());

        view.addObject("id", splInfoVO.getId());

        view.addObject("propId", id);
        view.addObject("isFlow", isFlow);

        //add 2017-8-8 14:25:22 by jiangzg
        if(StringUtils.isNotEmpty(isFlow) && BaseConstant.IS_YESNO_YES_STR.equals(isFlow) && StringUtils.isNotEmpty(taskDefKey)){
            String[] splitBranchKey = taskDefKey.split("_");
            view.addObject("currentBuOrgCd", splitBranchKey[1]);
        }else{
            view.addObject("currentBuOrgCd", CurrentThreadContext.getCurrentBuOrgCd());
        }
        // 是否显示合同续签页签
        if (CurrentThreadContext.getCurrentBuOrgCd().equals("0000") ||
                CurrentThreadContext.getCurrentBuOrgCd().equals("00000001")) {
            view.addObject("isShowSplRenewProtocol", BaseConstant.IS_YESNO_YES);
        } else {
            view.addObject("isShowSplRenewProtocol", BaseConstant.IS_YESNO_NO);
        }

        if("FLOW_0000_003_002_001".equals(taskDefKey) && "信审中心审核".equals(taskNm)){
            view.addObject("audStsCd",1 );
            SplInfoDTO splInfoDTO = this.splExtInfoApiService.selectPrdSplInfonById(propInfo.getSplId(), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
            SplExtInfoDTO splExtInfoDTO = splInfoDTO.getSplExtInfoDTO();
            BaseLogUtils.newWebLogger("扩展表对象splExtInfo==>" + JSON.toJSONString(splExtInfoDTO)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();

            if (null != splExtInfoDTO) {
                String importDataSource = splExtInfoDTO.getImportDataSource();
                Integer importDataIsChange = splExtInfoDTO.getImportDataIsChange();
                if (StringUtils.isNotEmpty(importDataSource)
                        && importDataSource.equals(SplGrpRelInfoSrcEnum.SRC_QIANHAI.getRelInfoSrc())
                        && StringUtils.isNotEmpty(importDataIsChange)
                        && importDataIsChange == BaseConstant.IS_YESNO_NO) {
                    view.addObject("importDataNm", "带入");
                } else {
                    view.addObject("importDataNm", "手填");
                }
            } else {
                view.addObject("importDataNm", "手填");
            }
        }else{
            view.addObject("audStsCd",0 );
        }

        String isApply = request.getParameter("isApply");//经销商特殊业务变更中
        view.addObject("isApply", isApply);

        String isModify = request.getParameter("isModify");//经销商特殊业务支持修改
        view.addObject("isModify", isModify);

        String noStartFlow = request.getParameter("noStartFlow");//经销商准入时维护特殊业务标识
        view.addObject("noStartFlow", noStartFlow);

        return view;
    }

    @RequestMapping(value = "/initCarsGuarFiles.do", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public Object initLnkFileInfoList(HttpServletRequest request, HttpServletResponse response) {
            String splId = request.getParameter("dataId");//客户ID
            String cfgCd = request.getParameter("cfgCd");//附件配置编号
            String tabNm = request.getParameter("tabNm");//附件对应表名
            String cfgOrgCd = request.getParameter("cfgOrgCd") ;
            String cfgSysCd = request.getParameter("cfgSysCd") ;
            String inFlow = request.getParameter("inFlow");
            String propIdStr = request.getParameter("id");
            SysUlFilesRecQueryCondition qc = new SysUlFilesRecQueryCondition();
            qc.setPkId(splId);
            qc.setCfgCd(cfgCd);
            if(StringUtils.isNotEmpty(cfgSysCd)){
                qc.setSysCd(cfgSysCd);
            }else{
                qc.setSysCd(SplSystemConstant.SPL_SYS_CD);
            }
            if(StringUtils.isNotEmpty(cfgOrgCd)){
                qc.setOrgCd(cfgOrgCd);
            }else{
                qc.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);
            }
            if(StringUtils.isNotEmpty(tabNm)){
                qc.setTabNm(tabNm);
            }
            List<PrjFileInfoVO> list = new ArrayList<>();
            qc.setIsDel(BaseConstant.IS_YESNO_NO);
            List<PrjFileInfoVO> list1 = this.getUploadFileList(qc);
            List<PrjFileInfoVO> list2 = null;
            List<Long> delIds = new ArrayList<>() ;
            if(StringUtils.isNotEmpty(inFlow) && BaseConstant.IS_YESNO_YES_STR.equals(inFlow)){
                Long propId = null ;
                if(StringUtils.isEmpty(propIdStr)) {
                    SplPropInfoQueryCondition condition = new SplPropInfoQueryCondition();
                    condition.setIsDel(BaseConstant.IS_YESNO_NO);
                    condition.setIsValid(2);
                    condition.setSplId(Long.valueOf(splId));
                    condition.setPropTypCd("006");
                    List<SplPropInfoDTO> propInfoDTOList = this.splPropInfoApiService.getSplPropInfoList(condition);

                    if (CollectionUtils.isNotEmpty(propInfoDTOList)) {
                        for (SplPropInfoDTO propInfoDTO : propInfoDTOList) {
                            if (StringUtils.isNotEmpty(propInfoDTO.getPropInfo()) && propInfoDTO.getPropInfo().contains("7")) {
                                propId = propInfoDTO.getId();
                            }
                        }
                    }
                }else{
                    propId = Long.valueOf(propIdStr);
                }
                if(StringUtils.isNotEmpty(propId)){
                    SplPropApplyInfoQC applyQC = new SplPropApplyInfoQC();
                    applyQC.setPropId(propId);
                    applyQC.setIsDel(BaseConstant.IS_YESNO_NO);
                    applyQC.setIsValid(BaseConstant.IS_YESNO_YES);
                    applyQC.setAudStsCd(BaseConstant.IS_YESNO_YES_STR);
                    List<SplPropApplyInfoDTO> applyInfoDTOList = this.splPropApplyInfoApiService.searchList(applyQC);
                    if(CollectionUtils.isNotEmpty(applyInfoDTOList)){
                        if(StringUtils.isNotEmpty(applyInfoDTOList.get(0).getDeleteFileId())){
                            String[] ids = applyInfoDTOList.get(0).getDeleteFileId().split(";");
                            for (String s:ids) {
                                delIds.add(Long.valueOf(s));
                            }
                        }
                    }
                }
                qc.setPkId(propId+"");
                list2 =  this.getUploadFileList(qc);
                if(CollectionUtils.isNotEmpty(list2)){
                    for (PrjFileInfoVO vo1:list1) {
                        for (PrjFileInfoVO vo2:list2) {
                            if(vo1.getCfgDtlCd().equals(vo2.getCfgDtlCd())){
                                if(StringUtils.isEmpty(vo1.getFileId()) && StringUtils.isEmpty(vo2.getFileId())){
                                    list.add(vo1);
                                }else if(StringUtils.isNotEmpty(vo1.getFileId())&& StringUtils.isEmpty(vo2.getFileId())){
                                    if(!delIds.contains(vo1.getFileId())) {
                                        list.add(vo1);
                                    }
                                }else if(StringUtils.isEmpty(vo1.getFileId())&& StringUtils.isNotEmpty(vo2.getFileId())){
                                    if(!delIds.contains(vo2.getFileId())) {
                                        list.add(vo2);
                                    }
                                }else if(StringUtils.isNotEmpty(vo1.getFileId())&& StringUtils.isNotEmpty(vo2.getFileId())){
                                    if(!delIds.contains(vo1.getFileId())) {
                                        list.add(vo1);
                                    }
                                    if(!delIds.contains(vo2.getFileId())) {
                                        list.add(vo2);
                                    }
                                }
                            }
                        }
                    }
                }
            }else{
                list.addAll(list1);
            }
            ListPageVO listPageVO = null ;
            if (CollectionUtils.isNotEmpty(list)) {
                listPageVO =  new ListPageVO<PrjFileInfoVO>(list, list.size());
            }else{
                listPageVO =  new ListPageVO<PrjFileInfoVO>(new ArrayList<PrjFileInfoVO>(), 0);
            }
            BaseLogUtils.newWebLogger("数据DATA:"+JSON.toJSONString(listPageVO)).setLogOperType(LogOperEnum.RESP)
                    .setSysCd(cn.lionbridge.center.context.CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
         return listPageVO ;
    }

    /**
     * 初始化经销商变更资料列表
     */
    @RequestMapping(value = "/getSplLevelCfg.do", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public Object getSplLevelCfg(HttpServletRequest request, HttpServletResponse response) {
        DataResultVO resultVO = new DataResultVO(BaseConstant.IS_YESNO_YES,"获取成功");
        KeyValueVO kv = new KeyValueVO();
        kv.setKey("1");
        kv.setValue("一级");
        KeyValueVO kv2 = new KeyValueVO();
        kv2.setKey("2");
        kv2.setValue("二级");
        List<KeyValueVO> kvList = new ArrayList<>();
        resultVO.setData(kvList);
        return resultVO ;
    }

    private List<PrjFileInfoVO> getUploadFileList(SysUlFilesRecQueryCondition condition) throws BaseException {
        //查询资料配置，系统代码,组织架构代码,配置编号 ,业务主键
        SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
        ulDatCfgQueryCondition.setSysCd(condition.getSysCd());//系统代码
        ulDatCfgQueryCondition.setOrgCd(condition.getOrgCd());
        ulDatCfgQueryCondition.setDataId(String.valueOf(condition.getPkId()));//业务主键
        ulDatCfgQueryCondition.setIsValid(BaseConstant.IS_YESNO_YES);
        List<String> cfgCdList = new ArrayList<>();
        cfgCdList.add(condition.getCfgCd());//配置编号
        ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号集合
        List<SysUlDatCfgDTO> list = null ;
        if(StringUtils.isEmpty(condition.getPkId())){
            list =this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
        }else{
            list = this.uploadApiService.searchSysUlDatCfgListByDataId(ulDatCfgQueryCondition);
        }
        List<PrjFileInfoVO> voList = null;
        if (CollectionUtils.isNotEmpty(list)) {
            Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(cn.lionbridge.center.context.CurrentThreadContext.getCurrentSysCd(), cn.lionbridge.center.context.CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_MATE_AUD_STS_CD);
            voList = new ArrayList<>();
            PrjFileInfoVO vo;
            //设置路径
            String picServicePath = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_SERVER_PATH);
            for (SysUlDatCfgDTO dto : list) {
                for (SysUlDatCfgDtlDTO dtlDTO : dto.getSysUlDatCfgDtlDTOList()) {
                    vo = new PrjFileInfoVO();
                    if(StringUtils.isNotEmpty(condition.getPkId())) {
                        vo.setId(Long.valueOf(condition.getPkId()));//业务主键
                    }
                    vo.setCfgDtlCd(dtlDTO.getCfgDtlCd());//配置子编号
                    vo.setDatNm(dtlDTO.getDatNm());//配置名称
                    vo.setCfgCd(dtlDTO.getCfgCd());//配置编号
                    vo.setOrgCd(dtlDTO.getOrgCd());//配置组织架构代码
                    vo.setCfgNm(dto.getCfgNm());//配置子名称
                    vo.setFileId(dtlDTO.getRecId());//附件ID
                    //如果有HTTP开头说明是可以访问路径,无需干涉
                    if(StringUtils.isNotBlank(dtlDTO.getFilePath()) && !dtlDTO.getFilePath().startsWith("http") && StringUtils.isNotBlank(picServicePath)){
                        vo.setFilePath(picServicePath+dtlDTO.getFilePath());
                    }else{
                        vo.setFilePath(dtlDTO.getFilePath());
                    }
                    vo.setFileNm(dtlDTO.getRecFileNm());//上传名称
                    vo.setCrtTm(dtlDTO.getRecCrtTm());//上传时间
                    vo.setIsMust(dtlDTO.getIsMust());//是否必传
                    vo.setMaxNum(dtlDTO.getMaxNum());//最大上传数量
                    if (StringUtils.isNotBlank(dtlDTO.getRecAudStsCd())) {
                        vo.setAudStsCd(dtlDTO.getRecAudStsCd());//验证状态
                    } else {
                        vo.setAudStsCd("0");//验证状态
                    }

                    if (audStsCdMap != null && audStsCdMap.containsKey(vo.getAudStsCd())) {
                        vo.setAudStsCdNm(audStsCdMap.get(vo.getAudStsCd()));
                    }
                    voList.add(vo);
                }
            }
        }
        return voList;
    }

    public DataResultVO getCarsGuarVOByParams(HttpServletRequest request) throws BaseException{
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,"成功");
        SplCarsGuarDtlInfoVO vo = new SplCarsGuarDtlInfoVO();
        String levelCd = request.getParameter("levelCd");//供应商等级
        String guarLnkCompId = request.getParameter("guarLnkCompId");//代偿担保挂靠公司
        String validTmStarStr = request.getParameter("validTmStar");//有效期开始日期
        String validTmEndStr = request.getParameter("validTmEnd");//有效期结束日期
        String roadBicycleRate = request.getParameter("roadBicycleRate");//公路车首期比例
        String stopTruckRate = request.getParameter("stopTruckRate");//工程车首期比例
        String phaseOneCrAmt = request.getParameter("phaseOneCrAmt");//一期授信额度
        String chnLastYearSlAmt = request.getParameter("chnLastYearSlAmt");//渠道上年销售量
        String chnLnkAmt = request.getParameter("chnLnkAmt");//渠道挂靠量
        String fileParams = request.getParameter("fileParams");//附件信息
        String splId = request.getParameter("splId");
        String carsGuarId = request.getParameter("carsGuarId");
        if(StringUtils.isEmpty(levelCd)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("经销商渠道担保等级不能为空!");
            return result ;
        }
        if(StringUtils.isEmpty(validTmStarStr)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("渠道担保协议有效期不能为空!");
            return result ;
        }
        if(StringUtils.isEmpty(validTmEndStr)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("渠道担保协议有效期不能为空!");
            return result ;
        }
        if(StringUtils.isNotEmpty(roadBicycleRate) && Double.valueOf(roadBicycleRate) <=0){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("公路车首期比例不能小于0!");
            return result ;
        }
        if(StringUtils.isNotEmpty(stopTruckRate) && Double.valueOf(stopTruckRate) <=0){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("工程车首期比例不能小于0!");
            return result ;
        }
        if (StringUtils.isNotBlank(fileParams)) {
            List<PrjFileInfoVO> fileParamList = JSON.parseArray(fileParams, PrjFileInfoVO.class);
            if(CollectionUtils.isNotEmpty(fileParamList)){
                BaseLogUtils.newLogger("附件信息").setKeys("fileParamList.size()",fileParamList.size()+"").info();
                List<SysUlFilesRecVO> fileList = new ArrayList<>(fileParamList.size());
                SysUlFilesRecVO filesRecVO ;
                List<String> cfgDtlList = new ArrayList<>();
                for (PrjFileInfoVO fileInfoVO : fileParamList) {
                    cfgDtlList.add(fileInfoVO.getCfgDtlCd());
                }
                if("1".equals(levelCd) && !cfgDtlList.contains("20")){
                    result.setSuccess(BaseConstant.IS_YESNO_NO);
                    result.setInfo("请上传厂商授权书!");
                    return result ;
                }
                if("1".equals(levelCd) && !cfgDtlList.contains("30")){
                    result.setSuccess(BaseConstant.IS_YESNO_NO);
                    result.setInfo("近一年厂商进销存系统数据截图!");
                    return result ;
                }

                for (PrjFileInfoVO fileInfoVO : fileParamList) {
                    filesRecVO = new SysUlFilesRecVO();
                    if (StringUtils.isNotEmpty(fileInfoVO.getFileId())) {
                        filesRecVO.setId(fileInfoVO.getFileId());
                    }
                    if("10".equals(fileInfoVO.getCfgDtlCd()) &&StringUtils.isEmpty(fileInfoVO.getFileNm())){
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
                        result.setInfo("渠道代偿担保协议!");
                        return result ;
                    }
                    if("40".equals(fileInfoVO.getCfgDtlCd()) &&StringUtils.isEmpty(fileInfoVO.getFileNm())){
                        result.setSuccess(BaseConstant.IS_YESNO_NO);
                        result.setInfo("纳税申报表!");
                        return result ;
                    }
                    filesRecVO.setFilePath(fileInfoVO.getFilePath());
                    filesRecVO.setFileNm(fileInfoVO.getFileNm());
                    filesRecVO.setCfgCd(SplInfoFileCfgEnum.SPL023.getCode());
                    filesRecVO.setTabNm(SplInfoFileCfgEnum.SPL023.getTableNm());
                    filesRecVO.setSysCd(SplInfoFileCfgEnum.SPL023.getSysCd());
                    filesRecVO.setCfgDtlCd(fileInfoVO.getCfgDtlCd());
                    filesRecVO.setOrgCd(fileInfoVO.getOrgCd());
                    filesRecVO.setAbsLocPath(PropertiesCacheUtils.getProperty(SplInfoFileCfgEnum.SPL023.getUploadRootPath())+filesRecVO.getFilePath());
                    filesRecVO.setCrtTm(new Date());
                    filesRecVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    filesRecVO.setIsDel(BaseConstant.IS_YESNO_NO);
                    //默认验证状态:未验证
                    filesRecVO.setAudStsCd(PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_VALID_STATUS_CD_A));
                    fileList.add(filesRecVO);
                }
                vo.setFileList(fileList);
            }else{
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("请上传附件信息!");
                return result ;
            }
        }else{
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("请上传附件信息!");
            return result ;
        }
        vo.setLvlel(Integer.valueOf(levelCd));
        if (StringUtils.isNotEmpty(guarLnkCompId) && StringUtils.isNumeric(guarLnkCompId)) {
            vo.setGuarLnkCompId(Long.valueOf(guarLnkCompId));
        }
        if(StringUtils.isNotEmpty(validTmStarStr)) {
            vo.setValidTmStar(DateUtils.formatStringToDate(validTmStarStr, DateUtils.YYYY_MM_DD));
        }
        if(StringUtils.isNotEmpty(validTmEndStr)) {
            vo.setValidTmEnd(DateUtils.formatStringToDate(validTmEndStr, DateUtils.YYYY_MM_DD));
        }
        if(StringUtils.isNotEmpty(roadBicycleRate)) {
            vo.setRoadBicycleRate(Double.valueOf(roadBicycleRate));
        }
        if(StringUtils.isNotEmpty(stopTruckRate)) {
            vo.setStopTruckRate(Double.valueOf(stopTruckRate));
        }
        if (StringUtils.isNotEmpty(phaseOneCrAmt)) {
            if ("1".equals(levelCd) && (Long.parseLong(phaseOneCrAmt) < 0 || Long.parseLong(phaseOneCrAmt) > 10000000)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("请确认:一期授信额度X取值范围：0≤X≤10,000,000!");
                return result;
            } else if ("2".equals(levelCd) && (Long.parseLong(phaseOneCrAmt) < 0 || Long.parseLong(phaseOneCrAmt) > 2000000)) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("请确认:一期授信额度X取值范围：0≤X≤2,000,000!");
                return result;
            } else {
                vo.setPhaseOneCrAmt(phaseOneCrAmt);
            }
        }
        if (StringUtils.isNotEmpty(chnLastYearSlAmt)) {
            if (Long.parseLong(chnLastYearSlAmt) < 0) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("请确认:渠道上年销售量Y取值范围：0≤Y!");
                return result;
            } else {
                vo.setChnLastYearSlAmt(chnLastYearSlAmt);
            }
        }
        if (StringUtils.isNotEmpty(chnLnkAmt)) {
            long chnLnkAmtLong = Long.parseLong(chnLnkAmt);
            if (chnLnkAmtLong < 0) {
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("请确认:渠道挂靠量Z取值范围：0≤Z!");
                return result;
            } else {
                vo.setChnLnkAmt(chnLnkAmtLong);
            }
        }
        vo.setSplId(Long.valueOf(splId));
        vo.setIsDel(BaseConstant.IS_YESNO_NO);
        vo.setIsValid(BaseConstant.IS_YESNO_YES);
        if(StringUtils.isNotEmpty(carsGuarId)){
            vo.setId(Long.valueOf(carsGuarId));
            vo.setMdfTm(new Date());
            vo.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
        }else{
            vo.setCrtTm(new Date());
            vo.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
        }
        result.setData(vo);
        return result ;
    }

    @RequestMapping(value ="/modifyBigCustomerData.do",method = {RequestMethod.POST})
    @ResponseBody
    public Object modifyBigCustomerData(HttpServletRequest request,HttpServletResponse response) throws BaseException{
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,"新增成功");
        String prjLvlCd = request.getParameter("prjLvlCd");
        String splId = request.getParameter("splId");
        String fileParams = request.getParameter("fileParams");
        String propinfo  = request.getParameter("prop");
        String id = request.getParameter("id");
        String inFlow = request.getParameter("inFlow");
        String delFileIds = request.getParameter("delFileIds");
        String packageParams = request.getParameter("packageParams");
        String delPackageIds = request.getParameter("delPackageIds");
        if(StringUtils.isEmpty(propinfo)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("修改失败，特殊业务类型为空");
            return result;
        }
        if("true".equals(propinfo)){
            propinfo = "7";
        }
        if(StringUtils.isEmpty(prjLvlCd)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("修改失败，请选择经销商类型");
            return result;
        }
        if(StringUtils.isNotEmpty(packageParams)){
            List<SplPackageInfoVO> packageInfoVOList = JSON.parseArray(packageParams,SplPackageInfoVO.class);
            if(CollectionUtils.isNotEmpty(packageInfoVOList)){
                for (SplPackageInfoVO packageInfoVO:packageInfoVOList) {
                    packageInfoVO.setSplId(Long.valueOf(splId));
                    if(StringUtils.isEmpty(packageInfoVO.getId())){
                        packageInfoVO.setIsDel(BaseConstant.IS_YESNO_NO);
                        packageInfoVO.setIsValid(2);
                        packageInfoVO.setCrtTm(new Date());
                        packageInfoVO.setCrtUsrId(cn.lionbridge.center.context.CurrentThreadContext.getCurrentUserId());
                    }else{
                        packageInfoVO.setMdfTm(new Date());
                        packageInfoVO.setMdfUsrId(cn.lionbridge.center.context.CurrentThreadContext.getCurrentUserId());
                    }
                }
                this.splPackageInfoApiService.batchAddOrModify(SplPackageInfoVOTransform.toDTOList(packageInfoVOList));
            }
        }

        if(StringUtils.isNotEmpty(delFileIds)){
            String[] delids = delFileIds.split(",");
            delFileIds = "";
            for (int i = 0; i< delids.length; i++) {
                if(i == 0){
                    delFileIds = delids[i];
                }else{
                    delFileIds +=";";
                    delFileIds+=delids[i];
                }
            }
        }
        if(StringUtils.isNotEmpty(delPackageIds)){
            String[] delids = delPackageIds.split(",");
            delPackageIds = "";
            for (int i = 0; i< delids.length; i++) {
                if(i == 0){
                    delPackageIds = delids[i];
                }else{
                    delPackageIds +=";";
                    delPackageIds+=delids[i];
                }
            }
        }
        List<SysUlFilesRecDTO> addFileList = new ArrayList<>();
        List<SysUlFilesRecDTO> modifyFileList = new ArrayList<>();
        if (StringUtils.isNotBlank(fileParams)) {
            List<PrjFileInfoVO> fileParamList = JSON.parseArray(fileParams, PrjFileInfoVO.class);
            if(CollectionUtils.isNotEmpty(fileParamList)){
                BaseLogUtils.newLogger("附件信息").setKeys("fileParamList.size()",fileParamList.size()+"").info();
                SysUlFilesRecDTO filesRecDTO ;
                List<String> cfgDtlList = new ArrayList<>();
                for (PrjFileInfoVO fileInfoVO : fileParamList) {
                    cfgDtlList.add(fileInfoVO.getCfgDtlCd());
                }
                for (PrjFileInfoVO fileInfoVO : fileParamList) {
                    filesRecDTO = new SysUlFilesRecDTO();
                    filesRecDTO.setFilePath(fileInfoVO.getFilePath());
                    filesRecDTO.setFileNm(fileInfoVO.getFileNm());
                    filesRecDTO.setCfgCd(SplInfoFileCfgEnum.SPL024.getCode());
                    filesRecDTO.setTabNm(SplInfoFileCfgEnum.SPL024.getTableNm());
                    filesRecDTO.setSysCd(SplInfoFileCfgEnum.SPL024.getSysCd());
                    filesRecDTO.setCfgDtlCd(fileInfoVO.getCfgDtlCd());
                    filesRecDTO.setOrgCd(fileInfoVO.getOrgCd());
                    filesRecDTO.setAbsLocPath(PropertiesCacheUtils.getProperty(SplInfoFileCfgEnum.SPL024.getUploadRootPath())+fileInfoVO.getFilePath());
                    filesRecDTO.setCrtTm(new Date());
                    filesRecDTO.setPkId(splId);
                    filesRecDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    filesRecDTO.setIsDel(BaseConstant.IS_YESNO_NO);
                    //默认验证状态:未验证
                    if(StringUtils.isNotEmpty(fileInfoVO.getAudStsCd())){
                        filesRecDTO.setAudStsCd(fileInfoVO.getAudStsCd());
                    }else {
                        filesRecDTO.setAudStsCd(PropertiesCacheUtils.getProperty(fl.constant.facade.framework.constant.DictionaryConstant.CODE_GRP_VALID_STATUS_CD_A));
                    }
                    if (StringUtils.isNotEmpty(fileInfoVO.getFileId())) {
                        filesRecDTO.setId(fileInfoVO.getFileId());
                        modifyFileList.add(filesRecDTO);
                    }else{
                        addFileList.add(filesRecDTO);
                    }
                    //fileList.add(filesRecVO);
                }
                if(CollectionUtils.isNotEmpty(modifyFileList)){
                    this.uploadApiService.modifySysUlFilesRecList(modifyFileList);
                }
                /*if(CollectionUtils.isNotEmpty(addFileList)){
                    this.uploadApiService.addSysUlFilesRecList(addFileList);
                }*/
            }else{
                result.setSuccess(BaseConstant.IS_YESNO_NO);
                result.setInfo("请上传附件信息!");
                return result ;
            }
        }else {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("请上传附件信息!");
            return result ;
        }
        if(StringUtils.isEmpty(inFlow) || !BaseConstant.IS_YESNO_YES_STR.equals(inFlow)){
            SplPropInfoQueryCondition condition = new SplPropInfoQueryCondition();
            condition.setSplId(Long.valueOf(splId));
            //condition.setIsValid(BaseConstant.IS_YESNO_YES);
            condition.setIsDel(BaseConstant.IS_YESNO_NO);
            condition.setPropTypCd("006");
            List<SplPropInfoDTO> propList = this.splPropInfoApiService.getSplPropInfoList(condition);
            if(CollectionUtils.isNotEmpty(propList)){
                List<Long> dataIdList = new ArrayList<>();
                for (SplPropInfoDTO propInfoDTO:propList) {
                    dataIdList.add(propInfoDTO.getId());
                }
                //查询流程历史
                List<String> audStsCdList = new ArrayList<>(3);
                audStsCdList.add(FlowConstant.FLOW_CHECK_STATE_IN);
                audStsCdList.add(FlowConstant.FLOW_CHECK_STATE_REJECT);
                audStsCdList.add(FlowConstant.FLOW_CHECK_STATE_SUBMIT);
                SysFlowSHQueryCondition shQueryCondition = new SysFlowSHQueryCondition();
                shQueryCondition.setDataIdList(dataIdList);
                shQueryCondition.setBusTyp("049");
                shQueryCondition.setWordsInTheTable(SplInfoConstant.SPL_FLOW_S_H_SPL);
                shQueryCondition.setStatus(BaseConstant.IS_YESNO_YES);
                shQueryCondition.setSysCd(SplSystemConstant.FL_SYS_CD);
                shQueryCondition.setAudStsCdList(audStsCdList);
                List<SysFlowSHDTO> sysFlowSHDTOs = this.flowQueryApiService.searchFlowSHList(shQueryCondition);
                if(CollectionUtils.isNotEmpty(sysFlowSHDTOs)){
                    result.setInfo("变更中，不允许修改！");
                    result.setSuccess(BaseConstant.IS_YESNO_NO);
                    return result ;
                }
            }
            SplPropInfoDTO propDTO = new SplPropInfoDTO();
            propDTO.setSplId(Long.valueOf(splId));
            //propDTO.setPropInfo("8");
            propDTO.setPropInfo(propinfo);
            propDTO.setPropTypCd("006");
            propDTO.setIsValid(2);
            propDTO.setIsDel(BaseConstant.IS_YESNO_NO);
            propDTO.setCrtTm(new Date());
            propDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
            /*if(StringUtils.isNotEmpty(id)){
                SplPropApplyInfoQC applyQC = new SplPropApplyInfoQC();
                applyQC.setIsDel(BaseConstant.IS_YESNO_NO);
                applyQC.setAudStsCd("1");
                applyQC.setIsValid(BaseConstant.IS_YESNO_YES);
                applyQC.setPropId(Long.valueOf(id));
                List<SplPropApplyInfoDTO> applyInfoDTOS = this.splPropApplyInfoApiService.searchList(applyQC);
                SplPropApplyInfoDTO applyDTO = null ;
                if(CollectionUtils.isNotEmpty(applyInfoDTOS)){
                    applyDTO =applyInfoDTOS.get(0);
                    String deleteFileId = applyDTO.getDeleteFileId();
                    if(StringUtils.isNotEmpty(delFileIds)) {
                        if (StringUtils.isNotEmpty(deleteFileId)) {
                            deleteFileId += ";";
                            deleteFileId +=delFileIds ;
                            applyDTO.setDeleteFileId(deleteFileId);
                        }else{
                            applyDTO.setDeleteFileId(delFileIds);
                        }
                    }
                    if(CollectionUtils.isNotEmpty(addFileList)){
                        String addFileId = "";
                        if(StringUtils.isNotEmpty(applyDTO.getAddFileId())){
                            addFileId = applyDTO.getAddFileId();
                        }
                        for (SysUlFilesRecDTO filesRecDTO:addFileList) {
                            filesRecDTO.setPkId(id);
                            Long fileId = this.uploadApiService.addSysUlFilesRec(filesRecDTO);
                            addFileId+=";";
                            addFileId+=fileId;
                        }
                        applyDTO.setAddFileId(addFileId);
                    }
                    if(StringUtils.isNotEmpty(prjLvlCd)){
                        applyDTO.setPrjLvlCdB(prjLvlCd);
                    }
                    applyDTO.setMdfTm(new Date());
                    applyDTO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
                    this.splPropApplyInfoApiService.modify(applyDTO);
                }else{
                    applyDTO = new SplPropApplyInfoDTO();
                    if(StringUtils.isNotEmpty(delFileIds)) {
                        applyDTO.setDeleteFileId(delFileIds);
                    }
                    if(CollectionUtils.isNotEmpty(addFileList)){
                        String addFileId = "";
                        for (SysUlFilesRecDTO filesRecDTO:addFileList) {
                            filesRecDTO.setPkId(id);
                            Long fileId = this.uploadApiService.addSysUlFilesRec(filesRecDTO);
                            addFileId+=";";
                            addFileId+=fileId;
                        }
                        applyDTO.setAddFileId(addFileId);
                    }
                    if(StringUtils.isNotEmpty(prjLvlCd)){
                        applyDTO.setPrjLvlCdB(prjLvlCd);
                    }
                    applyDTO.setPropId(Long.valueOf(id));
                    applyDTO.setCrtTm(new Date());
                    applyDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                    applyDTO.setAudStsCd("1");
                    this.splPropApplyInfoApiService.add(applyDTO);
                }
                propDTO.setId(Long.valueOf(id));
                this.splPropInfoApiService.addSplPropInfoDTO(propDTO);
            }else {*/
                Long addId = this.splPropInfoApiService.addSplPropInfoDTO(propDTO);

                SplPropApplyInfoDTO applyDTO = new SplPropApplyInfoDTO();
                if(StringUtils.isNotEmpty(delFileIds)) {
                    applyDTO.setDeleteFileId(delFileIds);
                }
                if(StringUtils.isNotEmpty(delPackageIds)){
                    applyDTO.setDelPackageIds(delPackageIds);
                }
                if(CollectionUtils.isNotEmpty(addFileList)){
                    String addFileId = "";
                    for (SysUlFilesRecDTO filesRecDTO:addFileList) {
                        filesRecDTO.setPkId(addId+"");
                        Long fileId = this.uploadApiService.addSysUlFilesRec(filesRecDTO);
                        addFileId+=";";
                        addFileId+=fileId;
                    }
                    applyDTO.setAddFileId(addFileId);
                }
                if(StringUtils.isNotEmpty(prjLvlCd)){
                    applyDTO.setPrjLvlCdB(prjLvlCd);
                }
                applyDTO.setPropId(addId);
                applyDTO.setCrtTm(new Date());
                applyDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                applyDTO.setAudStsCd("1");
                this.splPropApplyInfoApiService.add(applyDTO);
                FlowStartedDTO flowStartedDTO = this.addFlowStart(addId, "049");
                if (flowStartedDTO != null && StringUtils.isNotBlank(flowStartedDTO.getNextOperUsrNames())) {
                    result.setInfo("下一个节点操作人:" + flowStartedDTO.getNextOperUsrNames());
                } else {
                    result.setInfo("流程发起成功");
                }
         //   }
        }else{
            SplPropApplyInfoQC applyQC = new SplPropApplyInfoQC();
            applyQC.setIsDel(BaseConstant.IS_YESNO_NO);
            applyQC.setAudStsCd("1");
            applyQC.setIsValid(BaseConstant.IS_YESNO_YES);
            applyQC.setPropId(Long.valueOf(id));
            List<SplPropApplyInfoDTO> applyInfoDTOS = this.splPropApplyInfoApiService.searchList(applyQC);
            SplPropApplyInfoDTO applyDTO = null ;
            if(CollectionUtils.isNotEmpty(applyInfoDTOS)){
                applyDTO =applyInfoDTOS.get(0);
                String deleteFileId = applyDTO.getDeleteFileId();
                if(StringUtils.isNotEmpty(delFileIds)) {
                    if (StringUtils.isNotEmpty(deleteFileId)) {
                        deleteFileId += ";";
                        deleteFileId +=delFileIds ;
                        applyDTO.setDeleteFileId(deleteFileId);
                    }else{
                        applyDTO.setDeleteFileId(delFileIds);
                    }
                }
                if(CollectionUtils.isNotEmpty(addFileList)){
                    String addFileId = null;
                    if(StringUtils.isNotEmpty(applyDTO.getAddFileId())){
                        addFileId = applyDTO.getAddFileId();
                    }
                    for (SysUlFilesRecDTO filesRecDTO:addFileList) {
                        filesRecDTO.setPkId(id);
                        Long fileId = this.uploadApiService.addSysUlFilesRec(filesRecDTO);
                        if(StringUtils.isEmpty(addFileId)){
                            addFileId=fileId.toString();
                        }else {
                            addFileId += ";";
                            addFileId += fileId;
                        }
                    }
                    applyDTO.setAddFileId(addFileId);
                }
                if(StringUtils.isNotEmpty(prjLvlCd)){
                    applyDTO.setPrjLvlCdB(prjLvlCd);
                }
                applyDTO.setMdfTm(new Date());
                applyDTO.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
                boolean modify = this.splPropApplyInfoApiService.modify(applyDTO);
                if(modify){
                    result.setInfo("流程中数据处理成功");
                    result.setSuccess(BaseConstant.IS_YESNO_YES);
                }
            }else{
                applyDTO = new SplPropApplyInfoDTO();
                String deleteFileId = applyDTO.getDeleteFileId();
                String deletePackageIds = applyDTO.getDelPackageIds();
                if(StringUtils.isNotEmpty(delFileIds)) {
                    if (StringUtils.isNotEmpty(deleteFileId)) {
                        deleteFileId += ";";
                        deleteFileId +=delFileIds ;
                        applyDTO.setDeleteFileId(deleteFileId);
                    }else{
                        applyDTO.setDeleteFileId(delFileIds);
                    }
                }
                if(StringUtils.isNotEmpty(delPackageIds)){
                    if(StringUtils.isNotEmpty(deletePackageIds)){
                        deletePackageIds+=";";
                        deletePackageIds+=delPackageIds;
                        applyDTO.setDelPackageIds(deletePackageIds);
                    }else{
                        applyDTO.setDelPackageIds(delPackageIds);
                    }
                }
                if(CollectionUtils.isNotEmpty(addFileList)){
                    String addFileId = null;
                    for (SysUlFilesRecDTO filesRecDTO:addFileList) {
                        filesRecDTO.setPkId(id);
                        Long fileId = this.uploadApiService.addSysUlFilesRec(filesRecDTO);
                        if(StringUtils.isEmpty(addFileId)){
                            addFileId=fileId.toString();
                        }else {
                            addFileId += ";";
                            addFileId += fileId;
                        }
                    }
                    applyDTO.setAddFileId(addFileId);
                }
                if(StringUtils.isNotEmpty(prjLvlCd)){
                    applyDTO.setPrjLvlCdB(prjLvlCd);
                }
                applyDTO.setPropId(Long.valueOf(id));
                applyDTO.setCrtTm(new Date());
                applyDTO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
                applyDTO.setAudStsCd("1");
                Long applyId = this.splPropApplyInfoApiService.add(applyDTO);
                if(StringUtils.isNotEmpty(applyId)){
                    result.setInfo("流程中数据处理成功");
                    result.setSuccess(BaseConstant.IS_YESNO_YES);
                }
            }
        }
        return result ;
    }

    @RequestMapping(value ="/initBigCustomerData.do",method = {RequestMethod.GET})
    @ResponseBody
    public Object initBigCustomerData(HttpServletRequest request,HttpServletResponse response) throws BaseException{
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,"获取成功");
        String id = request.getParameter("id");
        String splId = request.getParameter("splId");
        String inFlow = request.getParameter("inFlow");

        if(StringUtils.isEmpty(id) && StringUtils.isEmpty(splId)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("查询失败！参数为空");
            return result ;
        }
        List<String> dataList = new ArrayList<>();
        if(StringUtils.isNotEmpty(id)){
            SplPropInfoDTO dto = this.splPropInfoApiService.getById(Long.valueOf(id));
            if(null != dto && StringUtils.isNotEmpty(dto.getPropInfo())){
                if(dto.getPropInfo().contains("7")){
                    dataList.add("7");
                }
            }
            splId = dto.getSplId().toString();
        }else{
            SplPropInfoQueryCondition qc = new SplPropInfoQueryCondition();
            qc.setSplId(Long.valueOf(splId));
            qc.setPropTypCd("006");
            qc.setIsValid(BaseConstant.IS_YESNO_YES);
            qc.setIsDel(BaseConstant.IS_YESNO_NO);
            List<SplPropInfoDTO> dtoList = this.splPropInfoApiService.getSplPropInfoList(qc);
            if(CollectionUtils.isNotEmpty(dtoList)){
                if(StringUtils.isNotEmpty(dtoList.get(0).getPropInfo()) && dtoList.get(0).getPropInfo().contains("7")){
                    dataList.add("7");
                }
            }
        }
        SplInfoVO vo = this.prdSplInfoService.selectById(Long.valueOf(splId));
        JSONObject obj = new JSONObject();
        obj.put("prjLvlCd",vo.getPrjLvlCd());
        if(StringUtils.isNotEmpty(inFlow) && BaseConstant.IS_YESNO_YES_STR.equals(inFlow) && StringUtils.isNotEmpty(id)){
            SplPropApplyInfoQC applyQC = new SplPropApplyInfoQC();
            applyQC.setPropId(Long.valueOf(id));
            applyQC.setIsValid(BaseConstant.IS_YESNO_YES);
            applyQC.setAudStsCd(BaseConstant.IS_YESNO_YES_STR);
            applyQC.setIsDel(BaseConstant.IS_YESNO_NO);
            List<SplPropApplyInfoDTO> applyInfoDTOList = this.splPropApplyInfoApiService.searchList(applyQC);
            if(CollectionUtils.isNotEmpty(applyInfoDTOList) &&StringUtils.isNotEmpty(applyInfoDTOList.get(0).getPrjLvlCdB()) ){
                obj.put("prjLvlCd",applyInfoDTOList.get(0).getPrjLvlCdB());
            }
        }
        obj.put("dataList",dataList);
        result.setData(obj);
        return result ;
    }

    @RequestMapping(value ="/removePackageById.do",method = {RequestMethod.GET})
    @ResponseBody
    public Object removePackageById(HttpServletRequest request,HttpServletResponse response) throws BaseException{
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,"删除成功！");
        String id = request.getParameter("id");
        if(StringUtils.isEmpty(id)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("ID不能为空！");
            return result ;
        }
        boolean b = this.splPackageInfoApiService.removeById(Long.valueOf(id));
        if(!b){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("删除失败！");
        }
        return result ;
    }

    @RequestMapping(value ="/initPackageList.do",method = {RequestMethod.GET})
    @ResponseBody
    public Object initPackageList(HttpServletRequest request,HttpServletResponse response) throws BaseException{
        //DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES,"获取成功");
        String splId = request.getParameter("splId");
        String inFlow = request.getParameter("inFlow");
        SplPackageInfoQC qc = new SplPackageInfoQC();
        qc.setIsDel(BaseConstant.IS_YESNO_NO);
        qc.setSplId(Long.valueOf(splId));
        if(StringUtils.isNotEmpty(inFlow) && BaseConstant.IS_YESNO_YES_STR.equals(inFlow)){
            qc.setIsValid(9);
        }else{
            qc.setIsValid(BaseConstant.IS_YESNO_YES);
        }
        List<SplPackageInfoDTO> dtoList = this.splPackageInfoApiService.searchList(qc);
        if(CollectionUtils.isNotEmpty(dtoList)) {
            ListPageVO<SplPackageInfoVO> listPageVO = new ListPageVO(SplPackageInfoVOTransform.toVOList(dtoList), dtoList.size());
            return listPageVO;
        }else{
            ListPageVO<SplPackageInfoVO> listPageVO = new ListPageVO(new ArrayList<SplPackageInfoVO>(),0);
            return listPageVO;
        }
    }
}
